const mongoose = require('mongoose')
const md5 = require('blueimp-md5')
// 创建约束对象
const userSchema = new mongoose.Schema({
  encrypt: String,
  username: { type: String, required: true },
  password: { type: String, require: true },
  phone: String,
  create_time: { type: Number, default: Date.now },
  role_id: { type: String, default: "63097dc98947cd391cd1168b" },
  name:{type:String, required:true},
  phone:{type:String,required:t=true},
  menus: Array,
});
const UserModel = mongoose.model('residential',userSchema)
UserModel.findOne({username:'admin'}).then(user => {
    if(!user){
        UserModel.create({encrypt:'admin',username:'admin',password:md5('admin')})
    }
})
module.exports = UserModel